(function(root, factory) {
	'use strict';
	if (typeof define === 'function' && define.amd) {
		// AMD. Register as an anonymous module.
		define(['exports', 'echarts'], factory);
	} else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
		// CommonJS
		factory(exports, require('echarts'));
	} else {
		// Browser globals
		factory({}, root.echarts);
	}


}(this, function(exports, echarts) {
	'use strict';
	var log = function(msg) {
		if (typeof console !== 'undefined') {
			console && console.error && console.error(msg);
		}
	};
	if (!echarts) {
		log('ECharts is not Loaded');
		return;
	}
	var contrastColor = '#71b69a';
	var axisCommon = {
		axisLine: {
			lineStyle: {
				color: contrastColor
			}
		},
		axisTick: {
			show: false,
			lineStyle: {
				color: contrastColor
			}
		},
		axisLabel: {
			textStyle: {
				color: contrastColor,
				fontSize: 12
			}
		},
		splitLine: {
			lineStyle: {
				color: contrastColor
			}
		},
		splitArea: {
			areaStyle: {
				color: contrastColor
			}
		}
	};
	echarts.registerTheme('theme', {
		color: ['#1B9A9F'],
		backgroundColor: 'rgba(0,0,0,0)',
		legend: {
			textStyle: {
				color: contrastColor,
				fontSize: 12,
				fontWeight: 'normal'
			},
			itemGap: 30
		},
		textStyle: {
			color: contrastColor,
			fontSize: 12
		},
		title: {
			textStyle: {
				fontSize: 14,
				fontWeight: 'bold',
				fontFamily: 'Microsoft YaHei',
				color: contrastColor
			},
			left: 'center',
			top: 'top'
		},
		line: {
			symbol: 'circle'
		},
		toolbox: {
			iconStyle: {
				normal: {
					brderColor: contrastColor
				}
			}
		},
		timeAxis: axisCommon,
		logAxis: axisCommon,
		valueAxis: axisCommon,
		categoryAxis: axisCommon,
		series: {
			smooth: true
		}
	});
}));

function getColors(ct, c1, c2) {
	var co1 = 'RGB(207, 233, 255)';
	var co2 = 'RGB(32, 147, 255)';
	if (c1 && c2) {
		co1 = c2;
		co2 = c1;
	}
	var reg = /\((.*?)\)/g;
	var reg2 = /\((.*?)\)/g;

	var arrCo1=reg.exec(co1)[1].split(',');
	var arrCo2=reg2.exec(co2)[1].split(',');
	for (var i = 0; i < 3; i++) {
		arrCo1[i]=parseInt(arrCo1[i]);
		arrCo2[i]=parseInt(arrCo2[i]);
	}

	var arrDif=[],avg=[],arrRes=[];
	for (var i = 0; i < 3; i++) {
		arrDif.push(arrCo1[i]-arrCo2[i]);
		avg.push(arrDif[i]/ct);
	}
	
	for (var i = 0; i < ct; i++) {
		arrRes.push('RGB('+parseInt(arrCo2[0])+', '+parseInt(arrCo2[1])+', '+parseInt(arrCo2[2])+')');
		arrCo2[0]+=avg[0];
		arrCo2[1]+=avg[1];
		arrCo2[2]+=avg[2];
	}
	
	return arrRes;
	
}